package cn.ccbfund.common.util;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

import org.apache.commons.beanutils.BeanUtils;

public class StringUtils {

	/**
	 * 返回Bean的所有属性字符串，格式如：Fund{fundCode=000001,fundType=1}
	 * @param bean
	 * @return
	 */
	public static String describe(Object bean) {
		StringBuilder sb = new StringBuilder();
		sb.append(bean.getClass().getName());
		sb.append("{");
		try {
			
			Map<String, String> properties = BeanUtils.describe(bean);
			properties.forEach((k,v)->{
				sb.append(k);
				sb.append("=");
				sb.append(v);
				sb.append(",");
			});
		} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
			e.printStackTrace();
		}
		sb.append("}");
		return sb.toString();
	
	}
}
